<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录页面</title>
    <link rel="stylesheet" href="../fonts/RemixIcon_Fonts/remixicon.css">
    <link rel="stylesheet" href="../css/base.css">
    <link rel="stylesheet" href="../css/load.css">
    <script src="../JS/jquery-3.6.0.js"></script>
    <script src="../JS/load.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
        integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

</head>

<body>
    <div class="side_box">
        <!-- 登录界面的透明div -->
        <div class="load_box">
            <p>宿舍管理系统</p>
            <!-- 登录中心的div -->
            <div class="load_center">
                <form class="form-horizontal">
                    <!-- 用户登录的div -->
                    <div class="form-group form_box_1">
                        <!-- 用户头像 -->
                        <label for="inputEmail3" class="col-sm-2 control-label"><i class="ri-user-3-line icon_comm"></i></label>  
                        <div class="col-sm-10 user_input">
                            <input type="text" class="form-control j_username" id="inputEmail3" placeholder="username">
                        </div>
                        <p class="p_opacity opac">请输入用户名</p>
                    </div>
                    
                    <!-- 输入密码的div -->
                    <div class="form-group form_box_2">
                        <!-- 密码图片 -->
                        <label for="inputPassword3" class="col-sm-2 control-label"><i class="ri-lock-line icon_comm"></i></label>
                        <div class="col-sm-10">
                            <input type="password" class="form-control j_password" id="inputPassword3" placeholder="password">
                        </div>
                        <p class="p_opacity opac">请输入密码</p>
                    </div>
                    
                    <div class="radio_box">
                        <input type="radio" name="111" class="type" value="学生"> 学生 
                        <input type="radio" name="111" class="type" value="管理员"> 管理员
                        <p class="p3_opacity opac">请选择登陆身份</p>
                    </div>
                    <!-- <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <div class="checkbox">
                                <label>
                                    <input type="radio"> 学生 
                                    <input type="radio"> 管理员
                                </label>
                              
                            </div>
                        </div>
                    </div> -->
                    <button type="button" class="btn btn-primary btn_add_css j_login">登录</button>
                </form>

            </div>


        </div>

    </div>


</body>

</html>
<script>
    $('.j_login').click(function(){
        $.ajax({
            url: '/api/login/getuser',
            data:{
                username:$('.j_username').val(),
                password:$('.j_password').val(),
                type:$('.type:checked').val()
            },
            type:'get',
            success:function(res){
                console.log(res);
                if(res.data.length){
                    alert('登录成功！');
                    if($('.type:checked').val() == '学生'){
                        window.location.href = '/project_k2/pages/stu_load_success.html';
                    }else {
                        window.location.href = '/project_k2/pages/admin_load_success.html';
                    }           
                }else {
                    alert('账号密码不存在！');
                }
        
            }
        })
        // if($('.j_username').val() == 'stu' && $('.j_password').val() == '11' && $('.type:checked').val() == '学生'){
        //     window.open('stu_load_success.html', '_blank');
        // }
        // if($('.j_username').val() == 'admin' && $('.j_password').val() == '11' && $('.type:checked').val() == '管理员'){
        //     window.open('admin_load_success.html', '_blank');
        // }
    })

    $('.j_username').on('blur', function(){
        var str = $('.j_username').val();
        if(!$('.j_username').trim()){
            
        }
        var reg = /\d{1,6}/;
        
        if(reg.test(str)){

        }

    })





</script>